package com.smile.frame.springbootsatoken.config;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 响应对象
 *
 * @author LGC
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -1455858674704802637L;
    /**
     * 状态码
     */
    private String code;
    /**
     * 提示信息
     */
    private String msg;
    /**
     * 具体对象信息
     */
    private T data;


    /**
     * 无数据对象成功返回
     *
     * @param <T>
     * @return
     */
    public static <T> Result<T> ok() {
        return Result.ok(null);
    }

    /**
     * 有数据对象成功返回
     *
     * @param t
     * @param <T>
     * @return
     */
    public static <T> Result<T> ok(T t) {
        Result<T> result = new Result<>();
        result.setCode("200");
        result.setMsg("成功");
        result.setData(t);
        return result;
    }


}
